﻿using System;
using Newtonsoft.Json.Serialization;

namespace Vecen.BangChuang.Json {
    internal class EmptyListValueProvider: IValueProvider {
        private readonly IValueProvider _provider;
        private readonly object defaultValue;

        public EmptyListValueProvider(IValueProvider provider, Type propType) {
            _provider = provider;
            defaultValue = new Object[] { };
        }

        public void SetValue(object target, object value) {
            _provider.SetValue(target, value);
        }

        public object GetValue(object target) {
            return _provider.GetValue(target) ?? defaultValue;
        }
    }
}